﻿using System;
using System.Reflection;

namespace ProdUi
{
    public class TestMethod : ITest
    {
        private readonly MethodInfo _method;

        public TestMethod(MethodInfo method)
        {
            foreach (Attribute attr in method.GetCustomAttributes(false))
            {
                TestProdAttribute att = attr as TestProdAttribute;
                if (att != null)
                {
                    if (att.Name == string.Empty) TestName = method.Name;
                    else TestName = att.Name;

                    _method = method;
                    TestDescription = att.Description;
                }
            }
        }

        #region ITest Members

        public string TestName { get; private set; }

        public string TestDescription { get; private set; }


        MethodInfo ITest.Method
        {
            get { return _method; }
        }

        #endregion
    }
}